package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.MainDataDailyPayBusinessTypeDTO;
import com.ctshk.rpc.system.req.*;
import com.ctshk.rpc.system.service.IMainDataDailyPayBusinessTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 日結業務類型表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-16
 */
@Api(value = "主數據日結業務類型",tags = "主數據日結業務類型")
@RestController
@RequestMapping("/main/data/daily/pay/business/type")
public class MainDataDailyPayBusinessTypeController extends BaseController {

    @DubboReference
    private IMainDataDailyPayBusinessTypeService mainDataDailyPayBusinessTypeService;

    /**
     * 新增日結業務類型
     * @param req
     * @return
     */
    @ApiOperation(value="新增日結業務類型", notes="新增日結業務類型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增日結業務類型", operDesc = "新增日結業務類型")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataDailyPayBusinessTypeReq req){
        return mainDataDailyPayBusinessTypeService.add(req,getCurrentUser(getRequest()));
    }
    /**
     * 編輯日結業務類型
     * @param req
     * @return
     */
    @ApiOperation(value="編輯日結業務類型", notes="編輯日結業務類型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯日結業務類型", operDesc = "編輯日結業務類型")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataDailyPayBusinessTypeReq req){
        return mainDataDailyPayBusinessTypeService.update(req,getCurrentUser(getRequest()));
    }

    /**
     * 查看日結業務類型
     * @param req
     * @return
     */
    @ApiOperation(value="查看日結業務類型", notes="查看日結業務類型")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看日結業務類型", operDesc = "查看日結業務類型")
    @PostMapping("/query")
    public Result<MainDataDailyPayBusinessTypeDTO> query(@RequestBody @Valid MainDataDailyPayBusinessTypeIdReq req){
        return Result.success(mainDataDailyPayBusinessTypeService.query(req));
    }

    /**
     * 查看日結業務類型列表
     * @param req
     * @return
     */
    @ApiOperation(value="查看日結業務類型列表", notes="查看日結業務類型列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看日結業務類型列表", operDesc = "查看日結業務類型列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataDailyPayBusinessTypeDTO>> list(@RequestBody @Valid MainDataDailyPayBusinessTypeListReq req){
        return Result.success(mainDataDailyPayBusinessTypeService.list(req));
    }

}
